<?php
class Model_ActionLog
{
	public static function getIp(){
		if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
	        $ip = $_SERVER['HTTP_CLIENT_IP'];
	    } else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
	        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
	    } else {
	        $ip = $_SERVER['REMOTE_ADDR'];
	    }
	
	    return $ip;
	}
	
	public static function actionLog($data) // offer detail
	{
		/*  init logs
		 */		
		$db = Zend_Registry::get("db");
		
		$ip = $data['ip'];
		$user_id = $data['user_id'];
		$client_id = $data['client_id'];
		$dpt_id = $data['dpt_id'];
		$dpt_account_id = $data['dpt_account_id'];
		$action = $data['action'];
		$memo = $data['memo']; 
		$query = "insert into action_log (date, ip, user_id, client_id, dpt_id, dpt_account_id, action, memo)
	              values (NOW(), '$ip', '$user_id', '$client_id', '$dpt_id', '$dpt_account_id', '$action', '$memo')";
	    //echo $query."\n";
	    $db->query($query);
	}
	
}

?>